import time
from threading import Thread


class MyThread(Thread):

    def __init__(self, name: str, count: int):
        super().__init__()
        # 该方法已弃用，使用name属性替换
        # self.setName()
        self.name = name  # 设置线程名称
        self.count = count

    def run(self) -> None:
        # 线程的任务脚本
        for i in range(self.count):
            print(f"{self.name} - {i}\n", end="")
            # 休眠10毫秒
            time.sleep(0.01)


t1 = MyThread("a", 10)
t2 = MyThread("b", 10)
t1.start()
t2.start()
